﻿// See https://aka.ms/new-console-template for more information
using Acl.Excel;

Console.WriteLine("Hello, World!");

var files = Directory.GetFiles(AppContext.BaseDirectory, "*.xlsx", SearchOption.AllDirectories);
foreach(var excelFile in files)
{
    //var excelFile = "822-0019 SCPV2_过线层P11线缆.xlsx";

    //取5行1列（第三列）数据，不包含列头
    var option = new ExcelQueryOptions() { ExcelFile = excelFile,
        SheetName ="BOM表",
        RowSize = 5,
        ColumnSize = 1,
        StartColumnNumber = 3,
         HasHeader = false,
    };
    var table = Acl.Excel.ExcelFile.Query(option);

    if (table.Count != 5)
    {
        throw new InvalidDataException($"{excelFile} 数据格式有误!");
    }

    //从第6行开始取8列的数据，包含列头
    option.ColumnSize = 8;
    option.StartRowNumber = 6;
    option.HasHeader = true;
    table = Acl.Excel.ExcelFile.Query(option);

    Console.WriteLine(table);

}

